package com.ringtheweb.persistence.dao;

import java.io.Serializable;
import java.util.List;



/**
 * An interface for all DAO operations.
 * <p>
 *   All CRUD operations on an entity are isolated in this interface
 * </p>
 * @param <T> the type of the entity to persist
 * @param <ID> the type of the entity's primary key
 * @author ldewavri
 *
 */
public interface IGenericDAO<T, ID extends Serializable> {
	

	/**
	 * Find an entity by its id
	 * @param id the primary key
	 * @param lock the locking mode
	 * @return the found entity
	 */
    T findById(ID id, boolean lock);

    
    /**
     * Return a list of all found entities
     * @return a {@link List} of type T
     */
    List<T> findAll();

    /**
     * Return a collection of entities that match the given example.
     * @param exampleInstance the example object
     * @param excludeProperty the properties to exclude 
     * @return a {@link List} of type T
     */
    List<T> findByExample(T exampleInstance, String... excludeProperty);

    /**
     * Persist the entity
     * @param entity entity to be persisted
     * @return the persisted entity
     */
    T makePersistent(T entity);
    
    /**
     * SaveOrUpdate the entity
     * @param entity entity to be persisted
     */
   void saveOrUpdate(T entity);    

    /**
     * Delete entity in database.
     * @param entity entity to be deleted
     */
    void makeTransient(T entity);
    
    
    /** 
     * Get count of entities in database
     * @return count
     */
	long getCount();
	

}
